//
//  SISSAgreementBrokerInfoView.m
//  SISSAPP
//
//  Created by 优房网 on 2017/7/19.
//  Copyright © 2017年 优房网. All rights reserved.
//

#import "SISSAgreementBrokerInfoView.h"

#import "SISSBrokerInfoModel.h"

@interface SISSAgreementBrokerInfoView ()

/// 发布方Label
@property (weak, nonatomic) UILabel *publisherLabel;
@property (weak, nonatomic) UILabel *publisherTitleLabel;
/// 备案证号Label
@property (weak, nonatomic) UILabel *certNoLabel;
@property (weak, nonatomic) UILabel *certNoTitleLabel;
/// 营业执照注册号Label
@property (weak, nonatomic) UILabel *businessLicenseLabel;
@property (weak, nonatomic) UILabel *businessLicenseTitleLabel;
/// 法定代表人Label
@property (weak, nonatomic) UILabel *legalPersonLabel;
@property (weak, nonatomic) UILabel *legalPersonTitleLabel;
/// 身份证/护照号码Label
@property (weak, nonatomic) UILabel *legalPersonIDCardNoLabel;
@property (weak, nonatomic) UILabel *legalPersonIDCardNoTitleLabel;
/// 通讯地址Label
@property (weak, nonatomic) UILabel *addressLabel;
@property (weak, nonatomic) UILabel *addressTitleLabel;
/// 联系电话Label
@property (weak, nonatomic) UILabel *telephoneLabel;
@property (weak, nonatomic) UILabel *telephoneTitleLabel;
/// 居间服务人员Label
@property (weak, nonatomic) UILabel *brokerLabel;
@property (weak, nonatomic) UILabel *brokerTitleLabel;
/// 身份证/护照号码Label
@property (weak, nonatomic) UILabel *brokerIDCardNoLabel;
@property (weak, nonatomic) UILabel *brokerIDCardNoTitleLabel;
/// 星级服务牌号Label
@property (weak, nonatomic) UILabel *starLevelLicenseLabel;
@property (weak, nonatomic) UILabel *starLevelLicenseTitleLabel;
/// 水印
@property (weak, nonatomic) UIImageView *waterMarkImageView;

@end
@implementation SISSAgreementBrokerInfoView



- (void)setBrokerInfoModel:(SISSBrokerInfoModel *)brokerInfoModel {
    _brokerInfoModel = brokerInfoModel;
    
    self.publisherLabel.text = brokerInfoModel.organ_name.length ? brokerInfoModel.organ_name : @" ";
    self.certNoLabel.text = brokerInfoModel.cert_no;
    self.businessLicenseLabel.text = brokerInfoModel.code;
    self.legalPersonLabel.text = brokerInfoModel.legal_person.length ? brokerInfoModel.legal_person : @" ";
    self.legalPersonIDCardNoLabel.text = brokerInfoModel.legal_person_idno.length ? brokerInfoModel.legal_person_idno : @" ";
    self.addressLabel.text = brokerInfoModel.office_address.length ? brokerInfoModel.office_address : @" ";
    self.telephoneLabel.text = brokerInfoModel.telephone;
    self.brokerLabel.text = brokerInfoModel.broker_name;
    self.brokerIDCardNoLabel.text = brokerInfoModel.idno;
    self.starLevelLicenseLabel.text = brokerInfoModel.license_no;
}

- (void)setPublisher:(NSString *)publisher {
    _publisher = publisher;
    
    self.publisherTitleLabel.text = self.publisher;
}

- (void)setIsShowBookingIntermediary:(BOOL)isShowBookingIntermediary {
    _isShowBookingIntermediary = isShowBookingIntermediary;
    if (isShowBookingIntermediary) {
        self.publisherTitleLabel.text = @"居间方";
        self.certNoTitleLabel.text = @"公司名称：";
        self.businessLicenseTitleLabel.text = @"备案证书号码：";
        self.legalPersonTitleLabel.text = @"法定代表人：";
        self.legalPersonIDCardNoTitleLabel.text = @"通讯地址：";
        self.addressTitleLabel.text = @"营业执照号码：";
        self.telephoneTitleLabel.text = @"联系电话：";
        self.brokerTitleLabel.text = @"居间服务人员：";
        self.brokerIDCardNoTitleLabel.text = @"牌号：";
        self.starLevelLicenseTitleLabel.text = @"联系电话：";
        
    }
}

- (void)setIntermediaryBrokerInfoModel:(SISSBrokerInfoModel *)intermediaryBrokerInfoModel {
    _intermediaryBrokerInfoModel = intermediaryBrokerInfoModel;
    
    self.publisherLabel.text = @" ";
    self.certNoLabel.text = intermediaryBrokerInfoModel.organ_name ? intermediaryBrokerInfoModel.organ_name : @" ";
    self.businessLicenseLabel.text = intermediaryBrokerInfoModel.cert_no;
    self.legalPersonLabel.text = intermediaryBrokerInfoModel.legal_person;
    self.legalPersonIDCardNoLabel.text = intermediaryBrokerInfoModel.office_address;
    self.addressLabel.text = intermediaryBrokerInfoModel.code;
    self.telephoneLabel.text = intermediaryBrokerInfoModel.telephone;
    self.brokerLabel.text = intermediaryBrokerInfoModel.broker_name;
    self.brokerIDCardNoLabel.text = intermediaryBrokerInfoModel.license_no;
    self.starLevelLicenseLabel.text = intermediaryBrokerInfoModel.license_no;
}

- (void)setIsShowWaterMark:(BOOL)isShowWaterMark {
    _isShowWaterMark = isShowWaterMark;
    
    self.waterMarkImageView.hidden = !isShowWaterMark;
}

#pragma mark - UI
- (void)initUI {
    [super initUI];
    self.backgroundColor = COLOR(0xF1F1F5);
    
    UILabel *publisherTitleLabel = [[UILabel alloc] init];
    publisherTitleLabel.text = @"甲方（发布方）：";
    publisherTitleLabel.textColor = COLOR(0x8998A5);
    publisherTitleLabel.font = [UIFont systemFontOfSize:15];
    [self addSubview:publisherTitleLabel];
    self.publisherTitleLabel = publisherTitleLabel;
    
    UILabel *publisherLabel = [[UILabel alloc] init];
    publisherLabel.text = @" ";
    publisherLabel.textColor = MAIN_TEXT_COLOR;
    publisherLabel.font = [UIFont boldSystemFontOfSize:15];
    publisherLabel.numberOfLines = 0;
    [self addSubview:publisherLabel];
    self.publisherLabel = publisherLabel;
    
    UILabel *certNoTitleLabel = [[UILabel alloc] init];
    certNoTitleLabel.text = @"备案证号：";
    certNoTitleLabel.textColor = COLOR(0x8998A5);
    certNoTitleLabel.font = [UIFont systemFontOfSize:15];
    [self addSubview:certNoTitleLabel];
    self.certNoTitleLabel = certNoTitleLabel;
    
    UILabel *certNoLabel = [[UILabel alloc] init];
    certNoLabel.text = @" ";
    certNoLabel.textColor = MAIN_TEXT_COLOR;
    certNoLabel.font = [UIFont boldSystemFontOfSize:15];
    [self addSubview:certNoLabel];
    self.certNoLabel = certNoLabel;
    
    UILabel *businessLicenseTitleLabel = [[UILabel alloc] init];
    businessLicenseTitleLabel.text = @"营业执照注册号：";
    businessLicenseTitleLabel.textColor = COLOR(0x8998A5);
    businessLicenseTitleLabel.font = [UIFont systemFontOfSize:15];
    [self addSubview:businessLicenseTitleLabel];
    self.businessLicenseTitleLabel = businessLicenseTitleLabel;
    
    UILabel *businessLicenseLabel = [[UILabel alloc] init];
    businessLicenseLabel.text = @" ";
    businessLicenseLabel.textColor = MAIN_TEXT_COLOR;
    businessLicenseLabel.font = [UIFont boldSystemFontOfSize:15];
    [self addSubview:businessLicenseLabel];
    self.businessLicenseLabel = businessLicenseLabel;
    
    UILabel *legalPersonTitleLabel = [[UILabel alloc] init];
    legalPersonTitleLabel.text = @"法定代表人：";
    legalPersonTitleLabel.textColor = COLOR(0x8998A5);
    legalPersonTitleLabel.font = [UIFont systemFontOfSize:15];
    [self addSubview:legalPersonTitleLabel];
    self.legalPersonTitleLabel = legalPersonTitleLabel;
    
    UILabel *legalPersonLabel = [[UILabel alloc] init];
    legalPersonLabel.text = @" ";
    legalPersonLabel.textColor = MAIN_TEXT_COLOR;
    legalPersonLabel.font = [UIFont boldSystemFontOfSize:15];
    [self addSubview:legalPersonLabel];
    self.legalPersonLabel = legalPersonLabel;
    
    UILabel *legalPersonIDCardNoTitleLabel = [[UILabel alloc] init];
    legalPersonIDCardNoTitleLabel.text = @"身份证/护照号码：";
    legalPersonIDCardNoTitleLabel.textColor = COLOR(0x8998A5);
    legalPersonIDCardNoTitleLabel.font = [UIFont systemFontOfSize:15];
    [self addSubview:legalPersonIDCardNoTitleLabel];
    self.legalPersonIDCardNoTitleLabel = legalPersonIDCardNoTitleLabel;
    
    UILabel *legalPersonIDCardNoLabel = [[UILabel alloc] init];
    legalPersonIDCardNoLabel.text = @" ";
    legalPersonIDCardNoLabel.textColor = MAIN_TEXT_COLOR;
    legalPersonIDCardNoLabel.font = [UIFont boldSystemFontOfSize:15];
    legalPersonIDCardNoLabel.numberOfLines = 0;
    [self addSubview:legalPersonIDCardNoLabel];
    self.legalPersonIDCardNoLabel = legalPersonIDCardNoLabel;
    
    UILabel *addressTitleLabel = [[UILabel alloc] init];
    addressTitleLabel.text = @"通讯地址：";
    addressTitleLabel.textColor = COLOR(0x8998A5);
    addressTitleLabel.font = [UIFont systemFontOfSize:15];
    [self addSubview:addressTitleLabel];
    self.addressTitleLabel = addressTitleLabel;
    
    UILabel *addressLabel = [[UILabel alloc] init];
    addressLabel.text = @" ";
    addressLabel.textColor = MAIN_TEXT_COLOR;
    addressLabel.font = [UIFont boldSystemFontOfSize:15];
    addressLabel.numberOfLines = 0;
    [self addSubview:addressLabel];
    self.addressLabel = addressLabel;
    
    UILabel *telephoneTitleLabel = [[UILabel alloc] init];
    telephoneTitleLabel.text = @"联系电话：";
    telephoneTitleLabel.textColor = COLOR(0x8998A5);
    telephoneTitleLabel.font = [UIFont systemFontOfSize:15];
    [self addSubview:telephoneTitleLabel];
    self.telephoneTitleLabel = telephoneTitleLabel;
    
    UILabel *telephoneLabel = [[UILabel alloc] init];
    telephoneLabel.text = @" ";
    telephoneLabel.textColor = MAIN_TEXT_COLOR;
    telephoneLabel.font = [UIFont boldSystemFontOfSize:15];
    [self addSubview:telephoneLabel];
    self.telephoneLabel = telephoneLabel;
    
    UILabel *brokerTitleLabel = [[UILabel alloc] init];
    brokerTitleLabel.text = @"居间服务人员：";
    brokerTitleLabel.textColor = COLOR(0x8998A5);
    brokerTitleLabel.font = [UIFont systemFontOfSize:15];
    [self addSubview:brokerTitleLabel];
    self.brokerTitleLabel = brokerTitleLabel;
    
    UILabel *brokerLabel = [[UILabel alloc] init];
    brokerLabel.text = @" ";
    brokerLabel.textColor = MAIN_TEXT_COLOR;
    brokerLabel.font = [UIFont boldSystemFontOfSize:15];
    [self addSubview:brokerLabel];
    self.brokerLabel = brokerLabel;
    
    UILabel *brokerIDCardNoTitleLabel = [[UILabel alloc] init];
    brokerIDCardNoTitleLabel.text = @"身份证/护照号码：";
    brokerIDCardNoTitleLabel.textColor = COLOR(0x8998A5);
    brokerIDCardNoTitleLabel.font = [UIFont systemFontOfSize:15];
    [self addSubview:brokerIDCardNoTitleLabel];
    self.brokerIDCardNoTitleLabel = brokerIDCardNoTitleLabel;
    
    UILabel *brokerIDCardNoLabel = [[UILabel alloc] init];
    brokerIDCardNoLabel.text = @" ";
    brokerIDCardNoLabel.textColor = MAIN_TEXT_COLOR;
    brokerIDCardNoLabel.font = [UIFont boldSystemFontOfSize:15];
    [self addSubview:brokerIDCardNoLabel];
    self.brokerIDCardNoLabel = brokerIDCardNoLabel;
    
    UILabel *starLevelLicenseTitleLabel = [[UILabel alloc] init];
    starLevelLicenseTitleLabel.text = @"星级服务牌号：";
    starLevelLicenseTitleLabel.textColor = COLOR(0x8998A5);
    starLevelLicenseTitleLabel.font = [UIFont systemFontOfSize:15];
    [self addSubview:starLevelLicenseTitleLabel];
    self.starLevelLicenseTitleLabel = starLevelLicenseTitleLabel;
    
    UILabel *starLevelLicenseLabel = [[UILabel alloc] init];
    starLevelLicenseLabel.text = @" ";
    starLevelLicenseLabel.textColor = MAIN_TEXT_COLOR;
    starLevelLicenseLabel.font = [UIFont boldSystemFontOfSize:15];
    [self addSubview:starLevelLicenseLabel];
    self.starLevelLicenseLabel = starLevelLicenseLabel;
    
    UIImageView *waterMarkImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"dataWaterMark"]];
    [waterMarkImageView sizeToFit];
    waterMarkImageView.hidden = YES;
    [self addSubview:waterMarkImageView];
    
    self.waterMarkImageView = waterMarkImageView;
}

#pragma mark - 布局
- (void)initConstraint {
    [super initConstraint];
    
    WeakSelf
    CGFloat margin = 8.0;
    [self.publisherTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf).offset(margin);
        make.top.equalTo(weakSelf).offset(3 * margin);
    }];
    [self.publisherLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.publisherTitleLabel.mas_right);
        make.top.equalTo(weakSelf.publisherTitleLabel);
        make.right.lessThanOrEqualTo(weakSelf).offset(-margin).priority(999);
    }];
    
    [self.certNoTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.publisherTitleLabel);
        make.top.equalTo(weakSelf.publisherLabel.mas_bottom).offset(2 * margin);
    }];
    [self.certNoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.certNoTitleLabel.mas_right);
        make.top.equalTo(weakSelf.certNoTitleLabel);
        make.right.lessThanOrEqualTo(weakSelf).offset(-margin).priority(999);
    }];
    
    [self.businessLicenseTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.certNoTitleLabel);
        make.top.equalTo(weakSelf.certNoTitleLabel.mas_bottom).offset(2 * margin);
    }];
    [self.businessLicenseLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.businessLicenseTitleLabel.mas_right);
        make.centerY.equalTo(weakSelf.businessLicenseTitleLabel);
    }];
    
    [self.legalPersonTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.businessLicenseTitleLabel);
        make.top.equalTo(weakSelf.businessLicenseTitleLabel.mas_bottom).offset(2 * margin);
    }];
    [self.legalPersonLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.legalPersonTitleLabel.mas_right);
        make.centerY.equalTo(weakSelf.legalPersonTitleLabel);
    }];
    
    [self.legalPersonIDCardNoTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.legalPersonTitleLabel);
        make.top.equalTo(weakSelf.legalPersonLabel.mas_bottom).offset(2 * margin);
    }];
    [self.legalPersonIDCardNoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.legalPersonIDCardNoTitleLabel.mas_right);
        make.top.equalTo(weakSelf.legalPersonIDCardNoTitleLabel);
        make.right.lessThanOrEqualTo(weakSelf).offset(-margin).priority(999);
    }];
    
    [self.addressTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.legalPersonIDCardNoTitleLabel);
        make.top.equalTo(weakSelf.legalPersonIDCardNoLabel.mas_bottom).offset(2 * margin);
    }];
    [self.addressLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.addressTitleLabel.mas_right);
        make.top.equalTo(weakSelf.addressTitleLabel);
        make.right.lessThanOrEqualTo(weakSelf).offset(-margin).priority(999);
    }];
    
    [self.telephoneTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.addressTitleLabel);
        make.top.equalTo(weakSelf.addressLabel.mas_bottom).offset(2 * margin);
    }];
    [self.telephoneLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.telephoneTitleLabel.mas_right);
        make.centerY.equalTo(weakSelf.telephoneTitleLabel);
    }];
    
    [self.brokerTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.telephoneTitleLabel);
        make.top.equalTo(weakSelf.telephoneTitleLabel.mas_bottom).offset(2 * margin);
    }];
    [self.brokerLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.brokerTitleLabel.mas_right);
        make.centerY.equalTo(weakSelf.brokerTitleLabel);
    }];
    
    [self.brokerIDCardNoTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.brokerTitleLabel);
        make.top.equalTo(weakSelf.brokerTitleLabel.mas_bottom).offset(2 * margin);
    }];
    [self.brokerIDCardNoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.brokerIDCardNoTitleLabel.mas_right);
        make.centerY.equalTo(weakSelf.brokerIDCardNoTitleLabel);
    }];
    
    [self.starLevelLicenseTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.brokerIDCardNoTitleLabel);
        make.top.equalTo(weakSelf.brokerIDCardNoTitleLabel.mas_bottom).offset(2 * margin);
        make.bottom.equalTo(weakSelf).offset(-margin);
    }];
    [self.starLevelLicenseLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.starLevelLicenseTitleLabel.mas_right);
        make.centerY.equalTo(weakSelf.starLevelLicenseTitleLabel);
    }];
    
    [self.waterMarkImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(weakSelf);
    }];
}



@end
